<div class="layuimini-main" id="DeviceReport-search">

    <form class="layui-form layui-form-pane" lay-filter="DeviceReport_search_div_filter">

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">时间范围：</label>
                <div class="layui-input-inline" style="margin-right: 0px;">
                    <input type="text" maxlength="30" name="reportBegin" lay-verify="required" autocomplete="off" class="layui-input" value="2021年7月5日">
                </div>
                <label class="layui-form-label">至</label>
                <div class="layui-input-inline">
                    <input type="text" maxlength="30" name="reportEnd" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">设备SN</label>
                <div class="layui-input-inline">
                    <input type="text" maxlength="30" name="deviceId" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">人员编号</label>
                <div class="layui-input-inline">
                    <input type="text" maxlength="10" name="employeeId" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">事件类型</label>
                <div class="layui-input-inline">
                    <select name="eventType" lay-verify="">
                        <option value="0" selected>(无)</option>
                        <option value="1">正常通行(已注册或者陌生人免验证)</option>
                        <option value="2">未注册（陌生人）</option>
                        <option value="3">有效期已过期或未到起始时间</option>
                        <option value="4">通行次数已用尽</option>
                        <option value="5">不在开门时段范围</option>
                        <option value="6">重复验证</option>
                        <option value="7">体温异常</option>
                        <option value="8">使用出门按钮开门</option>
                        <option value="100">开门超时报警</option>
                        <option value="101">门磁报警</option>
                        <option value="102">恢复出厂设置</option>
                        <option value="103">删除所有人</option>
                        <option value="104">开机</option>
                        <option value="106">WIFI 已连接</option>
                        <option value="107">WIFI 连接已断开</option>
                        <option value="108">消防报警</option>
                        <option value="109">关闭开门超时报警</option>
                        <option value="110">关闭门磁报警</option>
                        <option value="111">关闭消防报警</option>
                    </select>

                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-inline">
                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon">&#xe615;</i> 搜索</button>
                <button type="reset" class="layui-btn layui-btn-primary" id="btnreset">重置</button>
                <button type="submit" class="layui-btn layui-btn-primary" id="btnsearchclose"><i class="layui-icon">&#x1006;</i> 取消</button>
            </div>
        </div>
    </form>

</div>
<script>

    layui.use(['form', 'laydate',  'faceAPI'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        var laydate = layui.laydate;
        var faceAPI = layui.faceAPI;
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //执行一个laydate实例
        laydate.render({
            elem: '[name="reportBegin"]', //指定元素
            type: 'datetime',
        });


        //执行一个laydate实例
        laydate.render({
            elem: '[name="reportEnd"]', //指定元素
            type: 'datetime'
        });

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        if (faceAPI.DeviceReportSearchPageResult != null) {
            form.val("DeviceReport_search_div_filter", faceAPI.DeviceReportSearchPageResult.field);
        } else
            faceAPI.DeviceReportSearchPageResult = {};

        faceAPI.DeviceReportSearchPageResult.result = false;
        //监听提交
        form.on('submit(data-search-btn)', function (data) {
            var result = data.field;
            if (result.employeeId == "") result.employeeId = 0;
            if (result.eventType == "") result.eventType = 0;
            console.log(result);

            faceAPI.DeviceReportSearchPageResult.result = true;
            faceAPI.DeviceReportSearchPageResult.field = result;
            layer.close(parentIndex);
            return false;
        });


        $('#btnsearchclose').on('click', function () {
            faceAPI.DeviceReportSearchPageResult.result = false
            layer.close(parentIndex);
            return false;
        });

        $('[name="reportBegin"]').attr("value", dayjs().subtract(7, 'day').format("YYYY-MM-DD") + ' 00:00:00');
        $('[name="reportEnd"]').attr("value", dayjs().format("YYYY-MM-DD") + ' 23:59:59');
        


    });

</script>